package com.fmsz.xmly.adapters;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.fmsz.xmly.R;
import com.fmsz.xmly.entitys.findanchor.AnchorEntity;
import com.squareup.picasso.Picasso;

import java.util.ArrayList;


public class AnchorContentAdapter extends RecyclerView.Adapter<AnchorContentAdapter.ViewHolder>{
    private ArrayList datas;
    private Context context;

    public AnchorContentAdapter(Context context, ArrayList datas){
        this.context = context;
        this.datas = datas;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(context).inflate(R.layout.item_anchor_content,parent,false));
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        AnchorEntity.ListBean entity = (AnchorEntity.ListBean) datas.get(position);
        holder.tvTitle.setText(entity.getNickname());
        Picasso.with(context).load(entity.getSmallLogo()).into(holder.imageView);
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder{
        private ImageView imageView;
        private TextView tvTitle;

        public ViewHolder(View itemView){
            super(itemView);
            imageView = (ImageView) itemView.findViewById(R.id.iv);
            tvTitle = (TextView) itemView.findViewById(R.id.tv_name);
        }


    }
}
